const Sequelize = require("sequelize");

const sequelize = new Sequelize(
    process.env.DATA_BASE,
    process.env.DATA_BASE_USER,
    process.env.DATA_BASE_PASSWORD,
    {
        host: process.env.DATA_BASE_HOST,
        dialect: process.env.DIALECT,
        dialectModule: require(process.env.DIALECT_MODULE),
    }
);

sequelize
    .authenticate()
    .then(() => {
        console.log("Connection has been established successfully.");
    })
    .catch((err) => {
        console.log("Unable to connect to the database:", err);
    });

exports.sequelize = sequelize;
